package com.cqc.jdk8.Jutil.concurrent.locks.ReentrantLock.demo4;


import java.text.DateFormat;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

public class Counter {
    private final int count = 0;
    private final ReentrantLock lock = new ReentrantLock();

    public void f1() {
        lock.lock();
        try {
            System.out.println(DateFormat.getDateTimeInstance().format(new Date()) + "," + Thread.currentThread().getName());
            TimeUnit.SECONDS.sleep(5);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }


}
